package com.gaojiawei.multiThread11_ThreadPoolJDk;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class L03_CachedThreadPool {
    public static void main(String[] args) {
        ExecutorService cachedThreadPool = Executors.newCachedThreadPool();
        for(int i = 1;i < 300;i++){
            final int j = i;
            cachedThreadPool.execute(()->{
                System.out.println(Thread.currentThread().getName()+"    "+j);
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            });
        }
    }
}
